﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ReferentialsDataModel>" %>

<%@ Import Namespace="eCRAM.Model.CustomModel" %>

<%@ Import Namespace="eCRAM.WebSite.Models" %>
<%@ Import Namespace="eCRAM.WebSite.Tools" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Liste des données de références
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<form method="post" id="formFiltre">
    <fieldset><legend>Données à afficher</legend>
        <%= Html.DropDownListWithSubmitOnChange("SelectDataType", model => model.DataType, ViewData.GetEnumListItem<EnumDataType>().AddEmptyListItem(), "formFiltre", "")%>
    </fieldset>
</form>


<form method="post" id="formData">

    
    <h2><%= Model.Label %></h2>
    <%
        if(Model.DataType != 0)
        {
            if (!string.IsNullOrEmpty(Model.AddActionName))
            {
                Response.Write(Html.HyperLink(Model.AddActionName, Model.AddActionLabel, "formData"));
                Response.Write("<br />");
                Response.Write("<br />");

            }
            
            switch((EnumDataType)Model.DataType)
            {
                case EnumDataType.Activites:
                    Response.Write(Html.TableForItems(model => model.GetData<EditActivityModel>(), Model.GetTableDescription<EditActivityModel>(), Model.GetData<EditActivityModel>(), "formData"));
                    break;
                case EnumDataType.Utilisateurs:
                    Response.Write(Html.TableForItems(model => model.GetData<UserModel>(), Model.GetTableDescription<UserModel>(), Model.GetData<UserModel>(), "formData"));
                    break;
                case EnumDataType.Parametres:
                    Response.Write(Html.TableForItems(model => model.GetData<ParameterModel>(), Model.GetTableDescription<ParameterModel>(), Model.GetData<ParameterModel>(), "formData"));
                    break;
                case EnumDataType.ExportCram:
                    Response.Write(Html.TableForItems(model => model.GetData<CramSummary>(), Model.GetTableDescription<CramSummary>(), Model.GetData<CramSummary>(), "formData"));
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            Response.Write("<br />");
            if(!string.IsNullOrEmpty(Model.AddActionName))
            {
                Response.Write(Html.HyperLink(Model.AddActionName, Model.AddActionLabel, "formData"));
            }
            
        }
%>
    </form>
</asp:Content>
